<?php
/**
 * Ressource Document Popup
 *
 */
use Fox\Behaviors;
use Fox\Html\Header\Content;
use Fox\Generator;
use Fox\Html\Button;

$xview = Xview::instance();
$mission = $xview->component('missions', 'object');

// Customizing
$customizing = Hive\Mission\Customizing::instance();
$customizing->trackSummaryPage(array('mod' => 'missions','act'=>'documents'));

$upload = $xview->val('upload');
$ajax = $xview->val('xvtrs');
$reload =$xview->val('reload');
/* @var $ressource Hive\Mission */
$documents = $mission->allDocuments();
$title = new Content('documents',Msg(Hive::BUNDLE,Hive::MENU_DOCUMENTS));
$title->add(new Button('add','?'))
	->color(Button::COLOR_WARNING)
	->behaviors(Behaviors::action(
	Generator::url('documents','upload',null,array('inlineid' => $mission->getId(),'index'=> false,'classname' => $mission::className())),
	true
));

if($ajax)
{
	echo Xview::instance()->messages();
}

// Documents Block
$bkdoc = Xview::instance()->component('missions', 'documents',array('id' => $mission->getId()));
$bkdoc->item('documents')->setDatas($documents);
$bkdoc->item('documents')->bootstrapGrid();
$bkdoc->cssClass('jobUpdateBlock');

if($reload) {
	echo $bkdoc->item('documents')->render();
}
else {
	Xview::instance()->messages();
	echo $title->render();
	echo "<hr><div class=\"contentArea\">{$bkdoc->item("documents")->Display()}</div>";
}